package io.github.talelin.latticy.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.github.talelin.latticy.model.PaymentRejectRecordDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 支付拒绝记录Mapper
 */
@Mapper
public interface PaymentRejectRecordMapper extends BaseMapper<PaymentRejectRecordDO> {

    /**
     * 根据订单ID查询拒绝记录，按拒绝时间倒序排列
     */
    default List<PaymentRejectRecordDO> selectByOrderIdOrderByRejectTimeDesc(@Param("orderId") Long orderId) {
        QueryWrapper<PaymentRejectRecordDO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("order_id", orderId)
                   .orderByDesc("reject_time");
        return selectList(queryWrapper);
    }

    /**
     * 根据拒绝人ID查询拒绝记录，按拒绝时间倒序排列
     */
    default List<PaymentRejectRecordDO> selectByRejectByOrderByRejectTimeDesc(@Param("rejectBy") Long rejectBy) {
        QueryWrapper<PaymentRejectRecordDO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("reject_by", rejectBy)
                   .orderByDesc("reject_time");
        return selectList(queryWrapper);
    }
} 